# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
# from DataSpider.items import ZhipinItemLoader,ZhipinItem


class CiweishixiSpider(CrawlSpider):
    name = 'zhipin'
    allowed_domains = ['www.zhipin.com']
    start_urls = ['https://www.zhipin.com']
    headers={
        "Host": "www.zhipin.com",
        "Referer": "https://www.zhipin.com/?ka=header-home-logo",
        "Connection": "keep - alive",
        "Cookie": "sid=sem; JSESSIONID=""; __g=sem; __l=r=https%3A%2F%2Fwww.zhipin.com%2Fuser%2Fsem7.html%3Fsid%3Dsem%26qudao%3Dbdpc_baidu-%25E5%258D%258E%25E5%2593%2581%25E5%258D%259A%25E7%259D%25BF02A18KA0679%26plan%3DPC-%25E4%25BA%2592%25E8%2581%2594%25E7%25BD%2591%26unit%3D%25E4%25BA%2592%25E8%2581%2594%25E7%25BD%2591%25E7%25AB%259E%25E5%2593%2581-%25E7%259F%25AD%26keyword%3D%25E6%258B%2589%25E9%2592%25A9%26e_creative%3D36093342918%26bd_vid%3D7796608708721201749&l=https%253A%252F%252Fwww.zhipin.com%252Fuser%252Fsem7.html%253Fsid%253Dsem%2526qudao%253Dbdpc_baidu-%2525E5%25258D%25258E%2525E5%252593%252581%2525E5%25258D%25259A%2525E7%25259D%2525BF02A18KA0679%2526plan%253DPC-%2525E4%2525BA%252592%2525E8%252581%252594%2525E7%2525BD%252591%2526unit%253D%2525E4%2525BA%252592%2525E8%252581%252594%2525E7%2525BD%252591%2525E7%2525AB%25259E%2525E5%252593%252581-%2525E7%25259F%2525AD%2526keyword%253D%2525E6%25258B%252589%2525E9%252592%2525A9%2526e_creative%253D36093342918%2526bd_vid%253D7796608708721201749&g=%2Fwww.zhipin.com%2Fuser%2Fsem7.html%3Fsid%3Dsem%26qudao%3Dbdpc_baidu-%25E5%258D%258E%25E5%2593%2581%25E5%258D%259A%25E7%259D%25BF02A18KA0679%26plan%3D%25E8%25A1%258C%25E4%25B8%259A%25E5%25AE%259A%25E6%258A%2595-%25E6%25B5%258B%25E8%25AF%2595%26unit%3D%25E7%25BB%25BC%25E5%2590%2588-2%26keyword%3Dwww.zhipin.com%26bd_vid%3D10047673229130919879&friend_source=0&friend_source=0; __a=38732403.1583417481.1583417481.1583417495.148.2.147.148; Hm_lvt_194df3105ad7148dcf2b98a91b5e727a=1583417484,1583736034,1583743386,1583748835; Hm_lpvt_194df3105ad7148dcf2b98a91b5e727a=1583764307; __c=1583417495; lastCity=100010000; __zp_stoken__=6ee45tiySyvu%2Fba%2BWtndDSCnEfuYcbrQFwmV0DR9TQ3xnc0SLuhbeFoV4pU64w7%2BiTtwz75XiTBQFEJWnuIJET00EQm0HmCHK1m6zAYflDyzDvW9otA9H2rjurjk4yvIX1Uu; t=chSv1A5SMhn1aNGh; wt=chSv1A5SMhn1aNGh; toUrl=https%3A%2F%2Flogin.zhipin.com%2F%3Fka%3Dheader-login; _bl_uid=ddk947s1kmqc3dgnefU9xhs9UR1v",
        'token':'nhauBGMfanjQckh',
        "Upgrade-Insecure-Requests": "1",
        "Cache-Control": "max-age=0",
        'Upgrade - Insecure - Requests': '1',
    }

    rules = (
        # Rule(LinkExtractor(allow='xiaoyuan/.*'), follow=True),
        Rule(LinkExtractor(allow='[c].*[-].*'), follow=True),
        Rule(LinkExtractor(allow='job_detail/.*.html'), callback='parse_job', follow = True),
    )

    def parse_job(self, response):
        #解析boss直聘网职位信息
        # zhipin_item = ZhipinItem()
        # item_loader = ZhipinItemLoader(item=zhipin_item, response=response)

        # return item_loader.load_item()
        pass
